package com.example.day12_24_glide;

import android.os.Bundle;
import android.os.Environment;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.facebook.drawee.view.SimpleDraweeView;

import jp.wasabeef.glide.transformations.GrayscaleTransformation;


public class MainActivity extends AppCompatActivity {

    private ImageView iv;
    String path = Environment.getExternalStorageDirectory() + "/Pictures/t.jpg";
    String netUrl = "https://ww1.sinaimg.cn/large/0065oQSqly1ftu6gl83ewj30k80tites.jpg";
    private SimpleDraweeView sdv_fresco;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        iv = (ImageView) findViewById(R.id.iv);

        RequestOptions requestOptions = new RequestOptions();
        //圆形
//        requestOptions.circleCrop();

        //圆角
//        RoundedCorners roundedCorners = new RoundedCorners(2000);
//        requestOptions.transform(roundedCorners);

//        requestOptions.transform(new BlurTransformation());
        requestOptions.transform(new GrayscaleTransformation());

        Glide.with(this)
                .load(netUrl)
                .skipMemoryCache(true)//默认是false，代表有内存缓存，如果true，没有内存缓存
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)//默认AUTOMATIC
                .apply(requestOptions)
                .into(iv);
        sdv_fresco = (SimpleDraweeView) findViewById(R.id.sdv_fresco);

        sdv_fresco.setImageURI(netUrl);
    }
}
